package com.ffs.context;

/**
 * 处理器上下文（有界上下文，根据自己对DDD的理解进行的一个简单构思。）
 * 别喷！别喷！
 * @author ffs80 created 2021/7/3
 */
public class HandlerContext {

    private HandlerContext next;

    private AbstractHandler handler;

    private String resData;

    public HandlerContext(AbstractHandler handler, String resData) {
        this.handler = handler;
        this.resData = resData;
    }

    public HandlerContext(AbstractHandler handler) {
        this.handler = handler;
    }

    public void runNext(String param){
        if(next != null){
            next.setResData(this.resData);
            next.handler(param);
        }
    }

    public void handler(String param){
        this.handler.doHandler(this,param);
    }

    public HandlerContext getNext() {
        return next;
    }

    public void setNext(HandlerContext next) {
        this.next = next;
    }

    public AbstractHandler getHandler() {
        return handler;
    }

    public void setHandler(AbstractHandler handler) {
        this.handler = handler;
    }

    public String getResData() {
        return resData;
    }

    public void setResData(String resData) {
        this.resData = resData;
    }
}
